Field
This disclosure relates generally to host card emulation (HCE) and more specifically to a system and method for implementing an HCE command stack in a mobile phone.
Related Art
Contact-less smartcards based on near field communication (NFC) are commonly used for payment, building access, transit applications, and the like. Some Android-based mobile phones and other devices provide an NFC functionality called host card emulation (HCE) that allows the mobile phone to function as a smartcard for various applications. HCE processes commands in an instruction stack. The commands are received by, for example, the mobile phone and processed by a user application on the mobile phone. This is done through a command APDU (Application Protocol Data Unit) that includes application-level packets exchanged between an NFC reader and the HCE service in the mobile phone. The mobile phone receives and executes a command, and then sends a response APDU command back to the reader via the NFC field. A typical command sequence consists of 10-20 commands and responses.
One issue with HCE is that it may take a significant amount of time to receive the command APDU, process the command, and provide a response back to the NFC reader. Each time a command APDU is received, the command APDU moves upward in the stack from an NFC controller to the application. The application computes a response and then the response traverses downward in the stack back to the NFC controller. The time to traverse the HCE software stack in ‘upward’ (the command) and ‘downward’ (the response) directions dominates the time that it takes to execute the command. One reason that it takes a long time to traverse the HCE stack is due to context switches that are necessary to provide a secure system.
The longer the execution time of a command, the longer the user is required to hold the mobile phone against the NFC reader to successfully execute the transaction. A long execution time may be inconvenient for the user.
Therefore, a need exists for a method to reduce the execution time for commands and responses to traverse the HCE stack.